StockDividends.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use client';
  2. import '@/app/styles/data-table.scss';
  3. import DataTable, { DataTableColumn } from '@/components/table/DataTable';
  4. import { StockDividendRow, DIVIDEND_FIX_LABEL } from '@/types/seibro';
  5. import { codeLabel, formatDecimal, formatRatePercent, dateOrDash } from '@/lib/utils/market';
  6. function buildColumns(): DataTableColumn<StockDividendRow>[] {
  7. return [
  8. {
  9. key: 'rgtStdDt',
  10. header: '권리기준일',
  11. align: 'left',
  12. priority: 'high',
  13. cell: (row) => row.rgtStdDt
  14. },
  15. {
  16. key: 'xrgtDt',
  17. header: '권리락일',
  18. align: 'center',
  19. priority: 'medium',
  20. cell: (row) => dateOrDash(row.xrgtDt)
  21. },
  22. {
  23. key: 'cashPerShare',
  24. header: '주당배당금',
  25. align: 'right',
  26. priority: 'high',
  27. cell: (row) => (row.cashPerShare === null ? '—' : `${formatDecimal(row.cashPerShare, 0)}원`)
  28. },
  29. {
  30. key: 'marketDividendRate',
  31. header: '시가배당율',
  32. align: 'right',
  33. priority: 'high',
  34. cell: (row) => formatRatePercent(row.marketDividendRate)
  35. },
  36. {
  37. key: 'stockAllocRatio',
  38. header: '주식배정비율',
  39. align: 'right',
  40. priority: 'low',
  41. cell: (row) => (row.stockAllocRatio === null ? '—' : formatDecimal(row.stockAllocRatio, 4))
  42. },
  43. {
  44. key: 'cashPayDate',
  45. header: '지급일',
  46. align: 'center',
  47. priority: 'low',
  48. cell: (row) => dateOrDash(row.cashPayDate)
  49. },
  50. {
  51. key: 'fixType',
  52. header: '확정',
  53. align: 'center',
  54. priority: 'low',
  55. cell: (row) => codeLabel(row.fixType, DIVIDEND_FIX_LABEL)
  56. }
  57. ];
  58. }
  59. export default function StockDividends({ rows }: { rows: StockDividendRow[] })
  60. {
  61. return (
  62. <DataTable<StockDividendRow>
  63. caption='배당 이력 — 권리기준일, 권리락일, 주당배당금, 시가배당율, 주식배정비율, 지급일, 확정'
  64. columns={buildColumns()}
  65. rows={rows}
  66. rowKey={(row, index) => `${row.rgtStdDt}-${index}`}
  67. emptyMessage='수집된 배당 이력이 없습니다.'
  68. />
  69. );
  70. }